#ifndef PERSON_I_H
#define PERSON_I_H

#include <Person.h>
#include <IceUtil/Mutex.h>
#include <map>

class PersonI : public ::Demo::Person
{
public:

    PersonI(const ::std::string&, const ::std::string&);

    virtual ::std::string name(const ::Ice::Current&) const;
    virtual ::std::string getAddress(const ::Ice::Current&) const;
    virtual void setAddress(const ::std::string&, const ::Ice::Current&);
    virtual void destroy(const ::Ice::Current&);

    bool _isZombie() const;

private:

    ::std::string _name;
    ::std::string _addr;
    ::IceUtil::Mutex _m;
    bool _destroyed;
};
typedef ::IceUtil::Handle<PersonI> PersonIPtr;

class PersonFactoryI : public ::Demo::PersonFactory
{
public:

    PersonFactoryI() {}

    virtual ::Demo::PersonPrx create(const ::std::string&, const ::std::string&, const ::Ice::Current&);
    virtual ::Demo::PersonPrx find(const ::std::string&, const ::Ice::Current&) const;
    virtual ::Demo::PersonSeq list(const ::Ice::Current&) const;

private:
    typedef ::std::map< ::std::string, PersonIPtr> PMap;
    mutable PMap _persons;
    IceUtil::Mutex _lcMutex;
};
typedef ::IceUtil::Handle<PersonFactoryI> PersonFactoryIPtr;


#endif
